﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Cole.Entities;
using Microsoft.Practices.EnterpriseLibrary.Data;

using System.Data;

namespace Cole.Repository
{
    public class CursoRepository:MasterRepository,ICursoRepository
    {
        public List<Curso> GetCursoById(string criterio)
        {
            var query = _database.ExecuteSprocAccessor<Curso>("GetCursoById", criterio);
            return query.ToList();
        }

        public void ModificarCurso(Curso alu)
        {
            var command = _database.GetStoredProcCommand("RegistrarCurso");
            _database.AddInParameter(command, "id", DbType.Int32, alu.id);
            _database.AddInParameter(command, "Nombre", DbType.String, alu.Nombre);
            _database.AddInParameter(command, "Profesor", DbType.String, alu.Profesor);
            _database.AddInParameter(command, "Descripcion", DbType.String, alu.Descripcion);

            _database.ExecuteNonQuery(command);
        }

        public void EliminarCurso(int id)
        {
            var command = _database.GetStoredProcCommand("DeleteCurso");

            _database.AddInParameter(command, "id", DbType.Int32, id);

            _database.ExecuteNonQuery(command);
        }
    }
}
